package com.ay277.htqoa.thread;

/**
 * Created by accp09 on 2016/12/26.
 */
public class MyThread {
    public static void main(String[] args) {
        new MyThread1().start();
        new Thread(new MyThread2()).start();
    }
}
class  MyThread1 extends Thread{
    @Override
    public void run() {
        for (int i=1;i<=10;i++){
            synchronized ("a"){
            System.out.println("MyThread1----"+i);
                "a".notify();
                try {
                    "a".wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
class MyThread2 implements Runnable{
    @Override
    public void run() {
        for (int i=10;i>=1;i--){
            synchronized ("a"){
            System.out.println("MyThread2----"+i);
                "a".notify();
                try {
                    "a".wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
